Method for sharing data in local area network and electronic device

ABSTRACT

Embodiments of this application disclose a method for sharing data in a local area network and an electronic device. The method is as follows: A first electronic device establishes a wireless connection to a wireless access point, and receives, from a first port, access request information of a second electronic device forwarded by using the wireless access point, where the first port is a serving port for a local area network shared access protocol, and the second electronic device also establishes a wireless connection the wireless access point; the first electronic device verifies validity of the second electronic device; and if succeeds, the first electronic device sends access response information to the second electronic device, so that shared data in the first electronic device is accessed from the second electronic device, where the access response information includes an internal storage directory and a common file directory.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a national stage of International Application No.PCT/CN2018/080724, filed on Mar. 27, 2018, which is herein incorporatedby reference in its entirety.

TECHNICAL FIELD

Embodiments of this application relate to the terminal field, and inparticular, to a method for sharing data in a local area network and anelectronic device.

BACKGROUND

As terminal technologies continuously develop, mobile phones areincreasingly popularized. Because storage space of a mobile phone islimited or it is inconvenient for a user to edit and manage data such asa photo or a file by using the mobile phone, the user usually needs toaccess data (such as a photo, a video, or a file) in the mobile phone byusing a computer.

The prior art provides two solutions for accessing the data in themobile phone by using the computer: Solution 1: The mobile phone isconnected to the computer by using a universal serial bus (USB) cable.After the connection succeeds, the mobile phone is mapped as a storagedevice of the computer. In this way, the user can access the data storedin the mobile phone by using the computer. Solution 2: Correspondingmobile assistant software is installed on both the mobile phone and thecomputer, and the mobile phone and the computer may establish aconnection by using the mobile assistant software. After the connectionsucceeds, the user can access, from the computer, the data stored in themobile phone.

It can be learned that in the existing Solution 1, the data stored inthe mobile phone can be accessed from the computer only by using the USBcable, and in the existing Solution 2, the data stored in the mobilephone can be accessed from the computer only by installing thecorresponding software on both the mobile phone and the computer. Inaddition, when an operating system of the mobile phone is different froman operating system of the computer, even if the mobile phone isconnected to the computer by using the USB cable, the data stored in themobile phone cannot be accessed from the computer because the operatingsystem of the computer is incompatible with that of the mobile phone. Inthis case, dedicated software needs to be installed on the computer. Inconclusion, the data stored in the mobile phone cannot be quickly andconveniently accessed from the computer by using the existing twosolutions.

SUMMARY

Embodiments of this application provide a method for sharing data in alocal area network and an electronic device, to resolve a problem thatdata stored in a mobile phone cannot be quickly and convenientlyaccessed from a computer by using an existing solution.

To achieve the foregoing objective, the following technical solutionsare used in the embodiments of this application:

According to a first aspect of the embodiments of this application, amethod for sharing data in a local area network is provided, where themethod is implemented on a first electronic device with a touchscreen,and the method may include:

establishing, by the first electronic device, a wireless connection to awireless access point; receiving, by the first electronic device from afirst port, access request information of a second electronic deviceforwarded by using the wireless access point, where the first port is aserving port for a local area network shared access protocol, and thesecond electronic device also establishes a wireless connection to thewireless access point; verifying, by the first electronic device,validity of the second electronic device based on the access requestinformation; and if the first electronic device determines that theverification of the second electronic device succeeds, sending, by thefirst electronic device, access response information to the secondelectronic device by using the wireless access point, so that shareddata in the first electronic device is accessed from the secondelectronic device, where the access response information includes aninternal storage directory and a common file directory.

According to the method for sharing data in a local area networkprovided in this embodiment of this application, the first electronicdevice that supports the local area network shared access protocolreceives an operation of enabling a data sharing function, and enablesthe data sharing function in response to the operation, where the datasharing function is mainly used for a user to access the shared data inthe first electronic device from the second electronic device, and thesecond electronic device and the first electronic device are connectedto a same local area network. In this way, there is no need to installany software on the first electronic device and the second electronicdevice, there is no need to connect the first electronic device and thesecond electronic device by using a USB cable, and the data stored inthe first electronic device can be accessed quickly and convenientlyfrom the second electronic device, provided that the first electronicdevice and the second electronic device are connected to the same localarea network. In addition, both a Mac notebook computer of Apple andanother Windows' notebook computer support the local area network sharedaccess protocol. Therefore, even if an operating system of the firstelectronic device, for example, a mobile phone, is incompatible with anoperating system of a notebook computer, data stored in the mobile phonecan be accessed from the notebook computer by using the method in thisapplication. In addition, the access response information including theinternal storage directory and the common file directory is returned tothe second electronic device. This can help the user quickly find acommon file, and provide experience of operating a common folder for theuser.

With reference to the first aspect, in an implementation, before thereceiving, by the first electronic device from a first port, accessrequest information of a second electronic device forwarded by using thewireless access point, the method may further include: receiving, by thefirst electronic device, first input; and enabling, by the firstelectronic device, a data sharing function in response to the firstinput.

With reference to the first aspect or the foregoing possibleimplementation, in another possible implementation, the receiving, bythe first electronic device, first input may specifically include:displaying a share control screen on the touchscreen of the firstelectronic device, where the share control screen includes a shareon/off button; and receiving, by the first electronic device, the firstinput for the share on/off button.

With reference to the first aspect or the foregoing possibleimplementations, in another possible implementation, the wireless accesspoint is a Wi-Fi hotspot or a Bluetooth beacon; or the local areanetwork file sharing protocol is the SMB protocol; or the firstelectronic device is a mobile phone, and the second electronic device isa computer; or the common file directory includes at least one of thefollowing: an album directory, a music directory, and a video directory;or the first port is a transmission control protocol TCP port 139 or445.

With reference to the first aspect or the foregoing possibleimplementations, in another possible implementation, after theestablishing, by the first electronic device, a wireless connection to awireless access point, the method may further include: disabling, by thefirst electronic device, the data sharing function when determining thatthe wireless connection between the first electronic device and thewireless access point is disconnected. When detecting that the firstelectronic device is disconnected from the wireless access point, thefirst electronic device automatically disables the data sharingfunction, thereby reducing power consumption of a terminal.

With reference to the first aspect or the foregoing possibleimplementations, in another possible implementation, after theestablishing, by the first electronic device, a wireless connection to awireless access point, the method may further include: when determiningthat the wireless connection between the first electronic device and thewireless access point is disconnected and that a wireless connection isestablished to another wireless access point, displaying, by the firstelectronic device, prompt information on the touchscreen of the firstelectronic device, where the prompt information is used to indicate thatthe first electronic device has established the wireless connection tothe another wireless access point. In some embodiments, the firstelectronic device may further automatically disable the data sharingfunction. This can effectively prevent unauthorized access to the firstelectronic device by another electronic device connected to the newwireless access point, especially when the first electronic deviceallows password-free access.

According to a second aspect of the embodiments of this application, amethod for sharing data in a local area network is provided, where themethod may include:

establishing, by a first electronic device, a wireless connection to aWi-Fi hotspot; establishing, by a second electronic device, a wirelessconnection to the Wi-Fi hotspot; receiving, by the second electronicdevice, second input; displaying an identifier of the first electronicdevice on the second electronic device in response to the second input,where the identifier of the first electronic device includes a deviceicon and a to-be-discovered share name; receiving, by the secondelectronic device, third input; displaying a verification window on thesecond electronic device in response to the third input, where theverification window is used to prompt a user to enter a user name and apassword for login authentication; after receiving input confirmation,adding, by the second electronic device to access request information,the user name and the password that are entered by the user for loginauthentication, and sending the access request information to the firstelectronic device by using the Wi-Fi hotspot; receiving, by the firstelectronic device, the access request information from a first port,where the first port is a serving port for the SMB protocol; verifying,by the first electronic device, validity of the second electronic devicebased on the access request information; and if the first electronicdevice determines that the verification of the second electronic devicesucceeds, sending, by the first electronic device, access responseinformation to the second electronic device by using the Wi-Fi hotspot,so that shared data in the first electronic device is accessed from thesecond electronic device, where the access response information includesan internal storage directory and a common file directory.

According to the method for sharing data in a local area networkprovided in this embodiment of this application, the first electronicdevice that supports a local area network shared access protocolreceives an operation of enabling a data sharing function, and enablesthe data sharing function in response to the operation, where the datasharing function is mainly used for the user to access the shared datain the first electronic device from the second electronic device, andthe second electronic device and the first electronic device areconnected to a same local area network. In this way, there is no need toinstall any software on the first electronic device and the secondelectronic device, there is no need to connect the first electronicdevice and the second electronic device by using a USB cable, and thedata stored in the first electronic device can be accessed quickly andconveniently from the second electronic device, provided that the firstelectronic device and the second electronic device are connected to thesame local area network. In addition, both a Mac notebook computer ofApple and another Windows notebook computer support the local areanetwork shared access protocol. Therefore, even if an operating systemof the first electronic device, for example, a mobile phone, isincompatible with an operating system of a notebook computer, datastored in the mobile phone can be accessed from the notebook computer byusing the method in this application. In addition, the access responseinformation including the internal storage directory and the common filedirectory is returned to the second electronic device. This can help theuser quickly find a common file, and provide experience of operating acommon folder for the user.

With reference to the second aspect, in an implementation, before thereceiving, by the second electronic device, second input, the methodfurther includes: obtaining, by the first electronic device, a seconduser identifier of the second electronic device; determining, by thefirst electronic device, whether the second user identifier is the sameas a first user identifier stored in the first electronic device; if thefirst electronic device determines that the second user identifier isthe same as the first user identifier, automatically enabling, by thefirst electronic device, a data sharing function; and displaying, by thesecond electronic device, notification information, where thenotification information indicates that the first electronic device hasenabled the data sharing function. When determining that the second useridentifier of the second electronic device is the same as the first useridentifier stored in the first electronic device, the first electronicdevice automatically enables the data sharing function, therebyimproving user experience.

With reference to the second aspect or the foregoing possibleimplementation, in another possible implementation, before thereceiving, by the second electronic device, second input, the method mayfurther include: receiving, by the first electronic device, first input;and enabling, by the first electronic device, the data sharing functionin response to the first input.

With reference to the second aspect or the foregoing possibleimplementations, in another possible implementation, the identifier ofthe first electronic device and an identifier of a third electronicdevice are included in different directories in a network neighborhoodof the second electronic device, and the third electronic device is acomputer that has enabled a data sharing function. This can help theuser differentiate a device type of a share server discovered by thesecond electronic device.

With reference to the second aspect or the foregoing possibleimplementations, in another possible implementation, the first port is atransmission control protocol TCP port 139 or 445; and the common filedirectory includes at least one of the following: an album directory, amusic directory, and a video directory.

A third aspect of the embodiments of this application provides a systemfor sharing data in a local area network, where the system includes afirst electronic device and a second electronic device, and the firstelectronic device is a mobile phone running an Android operating system;

the first electronic device and the second electronic device areconnected to a same wireless access point; the first electronic devicereceives, from a first port, access request information of the secondelectronic device forwarded by using the wireless access point, wherethe first port is a serving port for a local area network shared accessprotocol; the first electronic device verifies validity of the secondelectronic device based on the access request information; and if thefirst electronic device determines that the verification of the secondelectronic device succeeds, the first electronic device sends accessresponse information to the second electronic device by using thewireless access point, so that shared data in the first electronicdevice is accessed from the second electronic device, where the accessresponse information includes an internal storage directory and a commonfile directory.

With reference to the third aspect, in an implementation, the secondelectronic device receives second input, and displays an identifier ofthe first electronic device on the second electronic device in responseto the second input, where the identifier of the first electronic deviceincludes a device icon and a to-be-discovered share name; the secondelectronic device receives third input, and displays a verificationwindow on the second electronic device in response to the third input,where the verification window is used to prompt a user to enter a username and a password for login authentication; and after receiving inputconfirmation, the second electronic device adds, to the access requestinformation, the user name and the password that are entered by the userfor login authentication, and sends the access request information tothe first electronic device by using the Wi-Fi hotspot.

With reference to the third aspect or the foregoing possibleimplementation, in another possible implementation, the identifier ofthe first electronic device and an identifier of a third electronicdevice are included in different directories in a network neighborhoodof the second electronic device, and the third electronic device is acomputer that has enabled a data sharing function.

According to a fourth aspect of the embodiments of this application, amethod for sharing data in a local area network is provided, where themethod includes:

establishing, by a seconds electronic device, a wireless connection to aWi-Fi hotspot; establishing, by a first electronic device, a wirelessconnection to the Wi-Fi hotspot; obtaining, by the first electronicdevice, a second user identifier of the second electronic device;determining, by the first electronic device, whether the second useridentifier is the same as a first user identifier stored in the firstelectronic device; if the first electronic device determines that thesecond user identifier is the same as the first user identifier,automatically enabling, by the first electronic device, a data sharingfunction; displaying, by the second electronic device, notificationinformation, where the notification information indicates that the firstelectronic device has enabled the data sharing function; receiving, bythe second electronic device, second input; displaying an identifier ofthe first electronic device on the second electronic device in responseto the second input, where the identifier of the first electronic deviceincludes a device icon and a to-be-discovered share name; receiving, bythe second electronic device, third input; displaying a verificationwindow on the second electronic device in response to the third input,where the verification window is used to prompt a user to enter a username and a password for login authentication; after receiving inputconfirmation, adding, by the second electronic device to access requestinformation, the user name and the password that are entered by the userfor login authentication, and sending the access request information tothe first electronic device by using the Wi-Fi hotspot; receiving, bythe first electronic device, the access request information from a firstport, where the first port is a serving port for the server messageblock SMB protocol; verifying, by the first electronic device, validityof the second electronic device based on the access request information;and if the first electronic device determines that the verification ofthe second electronic device succeeds, sending, by the first electronicdevice, access response information to the second electronic device byusing the Wi-Fi hotspot, so that shared data in the first electronicdevice is accessed from the second electronic device, where the accessresponse information includes an internal storage directory and a commonfile directory.

According to a fifth aspect of the embodiments of this application, anelectronic device is provided, where the electronic device may include:

a connection unit, configured to establish a wireless connection to awireless access point; a receiving unit, configured to receive, from afirst port, access request information of a second electronic deviceforwarded by using a wireless access point, where the first port is aserving port for a local area network shared access protocol, and thesecond electronic device establishes a wireless connection to thewireless access point; a verification unit, configured to verifyvalidity of the second electronic device based on the access requestinformation received by the receiving unit; and a sending unit,configured to: when the verification unit determines that theverification of the second electronic device succeeds, send accessresponse information to the second electronic device by using thewireless access point, so that shared data in the first electronicdevice is accessed from the second electronic device, where the accessresponse information includes an internal storage directory and a commonfile directory.

With reference to the fifth aspect, in an implementation, the electronicdevice may further include: an input unit, configured to receive firstinput; and a control unit, configured to enable a data sharing functionin response to the first input received by the input unit.

With reference to the fifth aspect or the foregoing possibleimplementation, in another possible implementation, the electronicdevice may further include: a display unit, configured to display ashare control screen, where the share control screen includes a shareon/off button; and the input unit is specifically configured to receivethe first input for the share on/off button.

With reference to the fifth aspect or the foregoing possibleimplementations, in another possible implementation, the wireless accesspoint is a wireless fidelity Wi-Fi hotspot or a Bluetooth beacon; or thelocal area network file sharing protocol is the server message block SMBprotocol; or the electronic device is a mobile phone, and the secondelectronic device is a computer; or the common file directory includesat least one of the following: an album directory, a music directory,and a video directory; or the first port is a transmission controlprotocol TCP port 139 or 445.

With reference to the fifth aspect or the foregoing possibleimplementations, in another possible implementation, the control unit isfurther configured to disable the data sharing function when it isdetermined that the wireless connection between the electronic deviceand the wireless access point is disconnected.

With reference to the fifth aspect or the foregoing possibleimplementations, in another possible implementation, the electronicdevice may further include: the display unit, configured to displayprompt information when it is determined that the wireless connectionbetween the electronic device and the wireless access point isdisconnected and that a wireless connection is established to anotherwireless access point, where the prompt information is used to indicatethat the electronic device establishes the wireless connection to theanother wireless access point.

According to a sixth aspect of the embodiments of this application, anelectronic device is provided, where the electronic device may includeone or more processors, one or more memories, and a touchscreen; the oneor more memories and the touchscreen are coupled to the one or moreprocessors; the one or more memories are configured to store computerprogram code, and the computer program code includes a computerinstruction; when the one or more processors execute the computerinstruction, the electronic device performs the method for sharing datain a local area network in any one of the first aspect or the possibleimplementations of the first aspect; and the touchscreen is configuredto display content according to an instruction of the processor.

According to a seventh aspect of the embodiments of this application, acomputer storage medium is provided, including a computer instruction.When the computer instruction is run on an electronic device, theelectronic device is enabled to perform the method for sharing data in alocal area network in any one of the first aspect or the possibleimplementations of the first aspect.

According to an eighth aspect of the embodiments of this application, acomputer program product is provided. When the computer program productis run on a computer, the computer is enabled to perform the method forsharing data in a local area network in any one of the first aspect orthe possible implementations of the first aspect.

According to a ninth aspect of the embodiments of this application, aprogram orchestration apparatus is provided, where the apparatus has afunction of implementing behavior of the electronic device in theforegoing method embodiments. The function may be implemented byhardware, or may be implemented by hardware executing correspondingsoftware. The hardware or the software includes one or more modulescorresponding to the foregoing function.

It should be understood that descriptions of technical features,technical solutions, beneficial effects, or similar words in thisapplication do not imply that all features and advantages can beimplemented in any individual embodiment. On the contrary, it may beunderstood that descriptions of the features or the beneficial effectsmean that at least one embodiment includes a specific technical feature,technical solution, or beneficial effect. Therefore, the descriptions ofthe technical features, the technical solutions, or the beneficialeffects in this specification may not necessarily belong to oneembodiment. Further, the technical features, the technical solutions,and the beneficial effects described in the embodiments may be combinedin any proper manner. A person skilled in the art understands that anembodiment may be implemented without one or more specific technicalfeatures, technical solutions, or beneficial effects in a specificembodiment. In other embodiments, additional technical features andbeneficial effects may further be identified in a specific embodimentthat does not reflect all the embodiments.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a simplified schematic diagram of a system architectureaccording to an embodiment of this application;

FIG. 2 is a schematic diagram of a hardware structure of a mobile phoneaccording to an embodiment of this application;

FIG. 3 is a schematic diagram of a software architecture that can be runon an electronic device according to an embodiment of this application;

FIG. 4 is a schematic flowchart of a method for sharing data in a localarea network according to an embodiment of this application;

FIG. 5(a) and FIG. 5(b) are schematic diagrams of some graphical userinterfaces displayed on an electronic device according to someembodiments of this application;

FIG. 6 is a schematic diagram of some graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 7(a) and FIG. 7(b) are schematic diagrams of some other graphicaluser interfaces displayed on an electronic device according to someother embodiments of this application;

FIG. 8 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 9A and FIG. 9B are a schematic flowchart of a method for sharingdata in a local area network according to another embodiment of thisapplication;

FIG. 10 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 11 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 12 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 13 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 14 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 15 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 16 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 17 is a schematic diagram of some other graphical user interfacesdisplayed on an electronic device according to some other embodiments ofthis application;

FIG. 18 is a schematic composition diagram of an electronic deviceaccording to an embodiment of this application; and

FIG. 19 is a schematic composition diagram of another electronic deviceaccording to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

The following terms “first” and “second” are merely intended for apurpose of description, and shall not be understood as an indication orimplication of relative importance or implicit indication of the numberof indicated technical features. Therefore, a feature limited by “first”or “second” may explicitly or implicitly include one or more features.In the description of the embodiments of this application, unlessotherwise stated, “a plurality of” means two or more than two.

An embodiment of this application provides a method for sharing data ina local area network. The method may be applied to an electronic devicethat supports a local area network shared access protocol. According tothe method for sharing data in a local area network, there is no need toinstall any software on the electronic device and another electronicdevice, there is no need to connect the electronic device and theanother electronic device by using a USB cable, and therefore datastored in the electronic device can be accessed quickly and convenientlyfrom the another electronic device. The another electronic device may bea device serving as a share client to access the electronic device.

FIG. 1 is a simplified schematic diagram of a system architectureaccording to an embodiment of this application. As shown in FIG. 1, thesystem architecture may include a first electronic device 101 and asecond electronic device 102. The first electronic device 101 and thesecond electronic device 102 are connected to a same local area network.That the first electronic device 101 and the second electronic device102 are connected to a same local area network may be specifically thatthe first electronic device 101 and the second electronic device 102establish wireless connections to a same wireless access point. Forexample, the first electronic device 101 and the second electronicdevice 102 are connected to a same wireless fidelity (WI-FI) hotspot.For another example, the first electronic device 101 and the secondelectronic device 102 may be connected to a same Bluetooth beacon byusing a Bluetooth protocol.

The first electronic device 101 supports a local area network sharedaccess protocol, and may serve as a share server to provide shared data.For example, the first electronic device 101 may be a mobile phone, atablet computer, or the like. A specific structure of the firstelectronic device 101 is shown in FIG. 2, and is specifically describedin the following embodiment.

The second electronic device 102 also supports the local area networkshared access protocol, and may serve as a share client to access theshared data in the first electronic device 101. In some embodiments, thesecond electronic device 102 may be specifically a mobile phone or acomputer. The computer may be a desktop computer, or may be a notebookcomputer, for example, a Mac notebook computer of Apple or a Windowsnotebook computer of Huawei.

In some embodiments of this application, the local area network sharedaccess protocol may be the server message block (SMB) protocol. The SMBprotocol is a communications protocol used for sharing resources such asa file and a printer on a local area network and providing services forsharing the resources such as a file and a printer between differentcomputers on the local area network. The SMB protocol is a client/serverand request/response protocol. By using the SMB protocol, a client mayread and write a file in a server in various network environments, andsend a service request to the server. In addition, the client mayfurther access resources such as a file, a printer, a mailslot, and anamed pipe on a remote server by using the SMB protocol. Specifically,in a TCP/IP environment, the client may establish a connection to theserver by using NetBIOS over TCP/IP (or NetBEUI/TCP, or SPX/IPX). Afterthe connection succeeds, the client may send an SMB command to theserver, so that the client can access a shared directory, open a file,read and write a file, and perform all other operations that can beperformed on a file system. In some other embodiments of thisapplication, the local area network shared access protocol mayalternatively be the common internet file system (CIFS) protocol. TheCIFS protocol is a newly proposed protocol. The protocol is also aclient/server and request/response protocol. The CIFS protocol is oneversion of the SMB protocol. Similar to the SMB protocol, the CIFSprotocol runs at a higher layer and may be considered as animplementation of application protocols such as the file transferprotocol and the hypertext transfer protocol.

The following describes a first electronic device 101, a graphical userinterface (which may be referred to as GUI for short below) on such afirst electronic device 101, and an embodiment in which such a firstelectronic device 101 is used. In some embodiments of this application,the first electronic device 101 may be a portable electronic device,such as a mobile phone, a tablet computer, or a wearable device (forexample, a smartwatch) with a wireless communication function, thatfurther includes another function, for example, a personal digitalassistant function and/or a music player function. An example embodimentof the portable electronic device includes but is not limited to aportable electronic device using iOS®, Android®, Microsoft®, or anotheroperating system. The portable electronic device may also be anotherportable electronic device, for example, a laptop computer (Laptop) witha touch-sensitive surface (for example, a touch panel). It should befurther understood that, in some other embodiments of this application,the first electronic device 101 may not be the portable electronicdevice, but a desktop computer or a digital camera with atouch-sensitive surface (for example, a touch panel).

As shown in FIG. 2, in an embodiment of this application, that a firstelectronic device 101 is a mobile phone is used as an example todescribe the first electronic device 101 provided in this embodiment ofthis application. A person skilled in the art may understand that themobile phone shown in FIG. 2 is merely an example, and does notconstitute a limitation on the mobile phone. In addition, the mobilephone may have more or fewer components than those shown in the figure,or may combine two or more components, or may have different componentconfigurations. The components shown in FIG. 2 may be implemented inhardware including one or more signal processing and/orapplication-specific integrated circuits, software, or a combination ofhardware and software.

As shown in FIG. 2, the mobile phone may specifically include componentssuch as a processor 201, a radio frequency (RF) circuit 202, a memory203, a touchscreen 204, a Bluetooth apparatus 205, one or more sensors206, a Wi-Fi apparatus 207, a positioning apparatus 208, an audiocircuit 209, a peripheral interface 210, and a power system 211. Thesecomponents may perform communication by using one or more communicationsbuses or signal cables (not shown in FIG. 2).

The following describes the components of the mobile phone in detailwith reference to FIG. 2.

The processor 201 is a control center of the mobile phone. The processor201 is connected to parts of the mobile phone by using variousinterfaces and cables, runs or executes an application (App) stored inthe memory 203, and invokes data and an instruction that are stored inthe memory 203, to perform various functions of the mobile phone andprocess data. In some embodiments, the processor 201 may include one ormore processing units. The processor 201 may further integrate anapplication processor and a modem processor. The application processormainly processes an operating system, a user interface, an application,and the like. The modem processor mainly processes wirelesscommunication. It should be understood that the modem processor may notbe integrated into the processor 201. For example, the processor 201 maybe a chip Kirin 960 manufactured by Huawei Technologies Co., Ltd. Insome embodiments of this application, the processor 201 may furtherinclude a fingerprint verification chip, configured to verify acollected fingerprint.

The radio frequency circuit 202 may be configured to send and receive aradio signal in an information receiving and sending process or a callprocess. Particularly, after receiving downlink data from a basestation, the radio frequency circuit 202 may send the downlink data tothe processor 201 for processing. In addition, the radio frequencycircuit 202 sends related uplink data to the base station. Generally,the radio frequency circuit 202 includes but is not limited to anantenna, at least one amplifier, a transceiver, a coupler, a low noiseamplifier, a duplexer, and the like. In addition, the radio frequencycircuit 202 may further communicate with another device through wirelesscommunication. The wireless communication may use any communicationsstandard or protocol, including but not limited to global system formobile communications, general packet radio service, code divisionmultiple access, wideband code division multiple access, long termevolution, email, SMS message service, and the like.

The memory 203 is configured to store an application and data. Theprocessor 201 runs the application and the data that are stored in thememory 203, to perform various functions of the mobile phone and processdata. The memory 203 mainly includes a program storage area and a datastorage area. The program storage area may store an operating system,and an application required by at least one function (for example, asound playing function and an image playing function). The data storagearea may store data (for example, audio data and a phone book) createdbased on use of the mobile phone. In addition, the memory 203 mayinclude a high-speed random access memory, and may further include anonvolatile memory such as a magnetic disk storage device and a flashmemory, or another nonvolatile solid-state storage device. The memory203 may store various operating systems such as an iOS® operating systemdeveloped by Apple and an Android® operating system developed by Google.

The touchscreen 204 may include a touch-sensitive surface 204-1 and adisplay 204-2. The touch-sensitive surface 204-1 (for example, a touchpanel) may collect a touch event performed by a user on or near themobile phone (for example, an operation performed by the user on thetouch-sensitive surface 204-1 or near the touch-sensitive surface 204-1by using any suitable object such as a finger or a stylus), and sendcollected touch information to another component, for example, theprocessor 201. The touch event performed by the user near thetouch-sensitive surface 204-1 may be referred to as a floating touch.The floating touch may mean that the user does not need to directlytouch the touchpad for selecting, moving, or dragging an object (forexample, an icon), and the user only needs to be near the electronicdevice to perform a desired function. In an application scenario of thefloating touch, terms such as “touch” and “contact” do not implicitlymean to directly touch the touchscreen, but to be near or close to thetouchscreen. The touch-sensitive surface 204-1 on which the floatingtouch can be performed may be implemented in a capacitive type, aninfrared photoreceptor type, an ultrasonic wave type, or the like. Thetouch-sensitive surface 204-1 may include two parts: a touch detectionapparatus and a touch controller. The touch detection apparatus detectsa touch orientation of the user, detects a signal generated by a touchoperation, and transmits the signal to the touch controller. The touchcontroller receives touch information from the touch detectionapparatus, converts the touch information into touch point coordinates,and sends the touch point coordinates to the processor 201. The touchcontroller may further receive an instruction sent by the processor 201,and execute the instruction. In addition, the touch-sensitive surface204-1 may be implemented in a plurality of types such as a resistivetype, a capacitive type, an infrared type, or a surface acoustic wavetype. The display 204-2 (also referred to as a display screen) may beconfigured to display information entered by the user or informationprovided for the user, and menus of the mobile phone. The display 204-2may be configured in a form such as a liquid crystal display or anorganic light emitting diode. The touch-sensitive surface 204-1 maycover the display 204-2. After detecting the touch event on or near thetouch-sensitive surface 204-1, the touch-sensitive surface 204-1transmits the touch event to the processor 201 to determine a type ofthe touch event. Then, the processor 201 may provide correspondingvisual output on the display 204-2 based on the type of the touch event.Although in FIG. 2, the touch-sensitive surface 204-1 and the displayscreen 204-2 are used as two independent components to implement inputand output functions of the mobile phone, in some embodiments, thetouch-sensitive surface 204-1 and the display screen 204-2 may beintegrated to implement the input and output functions of the mobilephone. It may be understood that the touchscreen 204 is formed bystacking a plurality of layers of materials. Only the touch-sensitivesurface (layer) and the display screen (layer) are presented in thisembodiment of this application, and other layers are not recorded inthis embodiment of this application. In addition, in some otherembodiments of this application, the touch-sensitive surface 204-1 maycover the display 204-2, and a size of the touch-sensitive surface 204-1is greater than a size of the display screen 204-2. Therefore, thedisplay screen 204-2 is entirely covered by the touch-sensitive surface204-1. Alternatively, the touch-sensitive surface 204-1 may be disposedon a front side of the mobile phone in a full panel form. In otherwords, any touch performed by the user on the front side of the mobilephone can be sensed by the mobile phone. In this way, full touch controlexperience on the front side of the mobile phone can be implemented. Insome other embodiments, the touch-sensitive surface 204-1 is disposed ona front side of the mobile phone in a full panel form, and the displayscreen 204-2 may also be disposed on the front side of the mobile phonein a full panel form. In this way, a bezel-less structure can beimplemented on the front side of the mobile phone.

The mobile phone may further include the Bluetooth apparatus 205,configured to exchange data between the mobile phone and anotherelectronic device (for example, a mobile phone or a smartwatch) over ashort distance. In this embodiment of this application, the Bluetoothapparatus may be an integrated circuit, a Bluetooth chip, or the like.

The mobile phone may further include at least one type of sensor 206,such as an optical sensor, a motion sensor, and another sensor.Specifically, the optical sensor may include an ambient light sensor anda proximity sensor. The ambient light sensor may adjust luminance of thedisplay of the touchscreen 204 based on intensity of ambient light. Theproximity sensor may power off the display when the mobile phone ismoved to an ear. As one type of the motion sensor, an accelerometersensor may detect acceleration values in all directions (usually onthree axes). The accelerometer sensor may detect a value and a directionof gravity when the accelerometer sensor is stationary, and may beapplied to an application for recognizing a posture of the mobile phone(such as switching between landscape mode and portrait mode, a relatedgame, or magnetometer posture calibration), a function related tovibration recognition (such as a pedometer or a knock), and the like.

In some embodiments of this application, the sensor 106 may furtherinclude a fingerprint sensor. For example, the fingerprint sensor may bedisposed on a back side of the mobile phone 100 (for example, below arear-facing camera), or the fingerprint sensor is disposed on the frontside of the mobile phone 100 (for example, below the touchscreen 104).In addition, the fingerprint sensor may be disposed on the touchscreen104 to implement a fingerprint recognition function. In other words, thefingerprint sensor may be integrated with the touchscreen 104 toimplement the fingerprint recognition function of the mobile phone 100.In this case, the fingerprint sensor may be disposed on the touchscreen104 as a part of the touchscreen 104, or may be disposed on thetouchscreen 104 in another manner. In addition, the fingerprint sensormay be further implemented as a full-panel fingerprint sensor. In thiscase, the touchscreen 104 may be considered as a panel on which afingerprint may be collected in any position. The fingerprint sensor maysend a collected fingerprint to the processor 101, so that the processor101 processes the fingerprint (for example, verify the fingerprint). Inthis embodiment of this application, the fingerprint sensor may use anytype of sensing technology, which includes but is not limited to anoptical sensing technology, a capacitive sensing technology, apiezoelectric sensing technology, an ultrasonic sensing technology, andthe like. In addition, for a specific technical solution of integratingthe fingerprint sensor into the touchscreen in this embodiment of thisapplication, refer to patent application No. US 2015/0036065 A1announced by the United States Patent and Trademark Office and entitled“FINGERPRINT SENSOR IN AN ELECTRONIC DEVICE”, whose controls areincorporated in this embodiment of this application by reference in itsentirety.

Other sensors such as a gyroscope, a barometer, a hygrometer, athermometer, and an infrared sensor may be further disposed on themobile phone. Details are not described herein.

The Wi-Fi apparatus 207 is configured to provide the mobile phone withnetwork access that complies with a Wi-Fi related standard or protocol.The mobile phone may access a Wi-Fi access point by using the Wi-Fiapparatus 207, to help the user send and receive an email, browse a webpage, access streaming media, and the like. The Wi-Fi apparatus 207provides wireless broadband internet access for the user. In some otherembodiments, the Wi-Fi apparatus 207 may be used as a Wi-Fi wirelessaccess point, and may provide Wi-Fi network access for anotherelectronic device.

The positioning apparatus 208 is configured to provide a geographiclocation for the mobile phone. It may be understood that the positioningapparatus 208 may be specifically a receiver of a positioning systemsuch as a global positioning system (GPS) or a BeiDou navigationsatellite system. After receiving a geographic location sent by thepositioning system, the positioning apparatus 208 sends the informationto the processor 201 for processing, or sends the information to thememory 203 for storage. In some other embodiments, the positioningapparatus 208 may alternatively be a receiver of an assisted globalpositioning system (AGPS). The AGPS runs in a manner in which GPSpositioning is performed with specific assistance. The AGPS can use asignal of a based station together with a GPS satellite signal, to speedup positioning performed by the mobile phone. In the AGPS system, thepositioning apparatus 208 may obtain positioning assistance throughcommunication with an assisted positioning server (for example, apositioning server of the mobile phone). The AGPS system assists thepositioning apparatus 208 as an assisted server, to implement rangingand positioning services. In this case, the assisted positioning servercommunicates with the positioning apparatus 208 (namely, a GPS receiver)of the electronic device such as the mobile phone by using a wirelesscommunications network, to provide positioning assistance.

The audio circuit 209, a speaker 212, and a microphone 213 may providean audio interface between the user and the mobile phone. In one aspect,the audio circuit 209 may convert received audio data into an electricalsignal and transmit the electrical signal to the speaker 212, and thespeaker 212 converts the electrical signal into a sound signal foroutput. In another aspect, the microphone 213 converts a collected soundsignal into an electrical signal, and the audio circuit 209 receives theelectrical signal, converts the electrical signal into audio data, andthen outputs the audio data to the RF circuit 202, to send the audiodata to, for example, another mobile phone, or outputs the audio data tothe memory 203 for further processing.

The peripheral interface 210 is configured to provide various interfacesfor an external input/output device (for example, a keyboard, a mouse, adisplay externally connected to the mobile phone, an external memory, ora subscriber identity module card). For example, the mobile phone isconnected to the mouse by using a universal serial bus interface, andthe mobile phone is connected, by using a metal contact on a card slotof the subscriber identity module (SIM) card, to the subscriber identitymodule card provided by a telecommunications operator. The peripheralinterface 210 may be configured to couple the external input/outputperipheral device to the processor 201 and the memory 203.

The mobile phone may further include the power supply apparatus 211 (forexample, a battery and a power supply management chip) that suppliespower to the components. The battery may be logically connected to theprocessor 201 by using the power supply management chip, so thatfunctions such as charging management, discharging management, and powerconsumption management are implemented by using the power supplyapparatus 211.

Although not shown in FIG. 2, the mobile phone may further include acamera (a front-facing camera and/or a rear-facing camera), a flash, amicro projection apparatus, a near field communication (NFC) apparatus,and the like. Details are not described herein.

For example, the memory 203 on the mobile phone may store an Android®operating system. The operating system is a Linux-based mobile deviceoperating system, and implements various functions by using theforegoing hardware on the mobile phone. The following describes asoftware architecture of the stored Android® operating system in detail.It should be noted that in this embodiment of this application, theAndroid® operating system is merely used as an example to describe asoftware environment required by a first electronic device to implementthe technical solutions in the embodiments. A person skilled in the artmay understand that this embodiment of this application can beimplemented by using another operating system.

For example, FIG. 3 is a schematic diagram of a software architecturethat can be run on the first electronic device. As shown in FIG. 3, thesoftware architecture may be divided into four layers: an applicationlayer 301, an application framework layer 302, a hardware abstractionlayer 303, and a Linux kernel layer 304.

The application layer 301 is the uppermost layer of the operatingsystem, and includes native applications in the operating system, suchas an email client, messages, phone, calendar, browser, and contacts.Certainly, a developer may compile an application and install theapplication at the layer. The application is usually developed by usinga Java language. This is implemented by invoking an applicationprogramming interface (API) provided at the application framework layer302. In some embodiments of this application, the application layer 301is mainly responsible for presenting a settings UI. The settings UI maybe used for the user to set a data sharing function of the firstelectronic device. For example, the user may enable or disable the datasharing function on the settings UI, and may further configure the datasharing function on the settings UI, for example, set a to-be-discoveredshare name and set a user name and a password for login authentication.For example, the settings UI may be a status bar or a notification bardisplayed on the touchscreen of the first electronic device, or may be ashare control screen displayed on the touchscreen of the firstelectronic device.

The application framework layer 302 mainly provides a developer withvarious APIs that can be used to access applications. The developer mayinteract with a bottom layer (for example, the hardware abstractionlayer or the Linux kernel layer) of the operating system by using anapplication framework, to develop an application of the developer. Theapplication framework mainly includes a series of services andmanagement systems of the Android® operating system. In some embodimentsof this application, the application framework layer 302 includes an SMBservice, and is mainly responsible for invoking a service interface usedfor communication with the hardware abstraction layer 303, to transfer arequest for enabling or disabling the data sharing function to thehardware abstraction layer 303. The application framework layer 302 isfurther responsible for managing device information, for example,managing the to-be-discovered share name and managing the user name andthe password for login authentication. For example, the SMB service mayinclude various modules configured to manage the data sharing function.For example, the SMB service includes a UI adapter, SMB settings, an SMBstate machine, a native controller, and the like. The SMB service mayfurther include a configuration file. In some other embodiments, thedata sharing function is implemented as a subfunction of an originalsharing function of the first electronic device. For example, a datasharing function is implemented as a subfunction of a Huawei Sharefunction of a Huawei mobile phone. In this case, the SMB service mayexist in the Huawei Share application in a form of a submodule, and atarget file path of the SMB service may besrc/main/java/com/huawei/android/hwshare/hwsync/. The UI adapter isconfigured to provide a service for the settings UI at the upper layer.For example, when the user performs an operation on a share on/offbutton for the data sharing function, the UI adapter may provide acorresponding service for the settings UI, to change a status (forexample, switching from an off state to an on state) of the share on/offbutton for the data sharing function on the settings UI. The SMBsettings service is mainly responsible for storing the to-be-discoveredshare name and/or the user name and the password for loginauthentication. The SMB state machine is mainly responsible formonitoring a running status of a share service at the bottom layer. Thenative controller is mainly responsible for controlling a signal at thebottom layer. The configuration file is used to store a shareddirectory, a file directory, a share scope setting for a user, and thelike.

The application framework layer 302 may further include a file observer(File Observer), a Wi-Fi service, and a notification manager. The threemodules are mainly responsible for cooperating with the SMB service toprovide the data sharing function. For example, the Wi-Fi service isused to monitor whether the first electronic device is connected to awireless access point. For another example, the notification manager isconfigured to transmit a notification message to the upper layer, sothat the notification message is presented on the touchscreen of thefirst electronic device.

The hardware abstraction layer (HAL) 303 is a support of the applicationframework, and an important link for connecting the applicationframework layer 302 and the Linux kernel layer 304. The hardwareabstraction layer 303 may provide a service for a developer by using theapplication framework layer 302. In some embodiments of thisapplication, the hardware abstraction layer 303 is mainly responsiblefor providing a service interface used for communication with theapplication framework layer 302, and further managing a share service,an SMB configuration file, smbpasswd, and the like. The SMBconfiguration file may be used to store the to-be-discovered share name.The smbpasswd may be used to store information such as the user name andthe password for login authentication. For example, a function of thehardware abstraction layer 303 in this embodiment of this applicationmay be implemented by configuring hwsyncd at the hardware abstractionlayer 303. The hwsyncd may be a subprocess individually constructed atthe hardware abstraction layer 303, and a target file path of thehwsyncd may be vendor/huawei/chipset_common/modules/fs/hwsyncd. Thehardware abstraction layer 303 may further include a daemon processsmbd/nmbd. The daemon process may be a subprocess individuallyconstructed at the hardware abstraction layer 303, and a target filepath of the daemon process may bevendor/huawei/chipset_common/modules/fs/samba server. The hwsyncd mayinclude modules such as an interface, an SMB controller, a sharing filecontroller , and an SMB configuration interface. The interface is theservice interface used for communication with the application frameworklayer 302. The SMB controller is configured to monitor an SMB serviceconfiguration at an upper layer, for example, control whetherauthentication needs to be performed. The sharing file controller ismainly responsible for monitoring whether a file in the first electronicdevice is updated. When an update occurs, the sharing file controllermay instruct the upper layer to update a shared directory and the like.

The Linux kernel layer 304 provides a core system service of theoperating system. For example, security, memory management, processmanagement, a network protocol stack, and a driver model are all basedon a Linux kernel. The Linux kernel is also used as an abstraction layerbetween hardware and a software stack. The layer has many driversrelated to the electronic device, mainly including a display driver, aLinux-based frame buffer driver, a driver of a keyboard used as an inputdevice, a flash driver that is based on a memory technology device, acamera driver, an audio driver, a Bluetooth driver, a Wi-Fi driver, andthe like. In some embodiments of this application, the Linux kernellayer 304 depends on a local file system. The local file system may beaccessed by using the share service, and shared data in the local filesystem may be configured by using the service interface at the hardwareabstraction layer 303.

All technical solutions in the following embodiments may be implementedon an electronic device that has the foregoing hardware architecture andsoftware architecture.

For example, FIG. 4 is a schematic flowchart of a method for sharingdata in a local area network according to an embodiment of thisapplication. As shown in FIG. 4, the method may include S401 and S402.

For ease of understanding, in this embodiment of this application, thata first electronic device is a mobile phone, a second electronic deviceis a notebook computer, and shared data in the mobile phone is accessedby using the notebook computer is used as an example to specificallydescribe the method for sharing data in a local area network provided inthis embodiment of this application.

S401: The first electronic device receives first input.

For example, the first input may be specifically an operation performedby a user on a share on/off button for a data sharing function of thefirst electronic device, and the on/off button is used to enable ordisable the data sharing function. The data sharing function may be afunction of providing a data sharing service between differentelectronic devices by using a local area network shared access protocol,for example, the SMB protocol. For example, Samba software may beinstalled on the mobile phone and two daemon processes smbd/nmbdincluded in the Samba software and another configuration may beadaptively modified, to implement the data sharing function of the firstelectronic device. The Samba software is software for implementing theSMB protocol.

In some embodiments of this application, the share on/off button for thedata sharing function may be included on a share control screen, or maybe included on a notification bar of the first electronic device. Forexample, in some embodiments, as shown in FIG. 5(a), the first input maybe an operation performed by the user on a share on/off button 502 forthe data sharing function on a share control screen 501 displayed on atouchscreen of the mobile phone. In response to the user's operation onthe share on/off button 502 for the data sharing function, a status ofthe share on/off button 502 for the data sharing function changes, forexample, switches from an off state (as shown in FIG. 5(a) and FIG.5(b)) to an on state (not shown in the figures).

In some other embodiments of this application, the data sharing functionmay be implemented as a subfunction of an original sharing function ofthe first electronic device. For example, a data sharing function of aHuawei mobile phone is implemented as a subfunction of a Huawei Sharefunction of the mobile phone. In this case, as shown in FIG. 6, thefirst input may be an operation performed by the user on an on/offbutton 602 for the Huawei Share function and on an on/off button 603 for“visible to a computer on a same network”, where the on/off button 602and the on/off button 603 are located on the share control screen, forexample, a control screen 601 for the Huawei Share function, displayedon the touchscreen of the mobile phone. The data sharing function of themobile phone is enabled only when both the on/off button 602 for theHuawei Share function and the on/off button 603 for “visible to acomputer on a same network” are enabled. A main function of the on/offbutton 602 for the Huawei Share function is to enable/disable the HuaweiShare function. The user may perform an operation on the on/off button602 for the Huawei Share function. After receiving the user's operationon the on/off button 602 for the Huawei Share function, the mobile phonemay invoke a related system service interface to enable/disable theHuawei Share function, and may switch a status (for example, switchingfrom an off state to an on state) of the on/off button 602 for theHuawei Share function in response to the user's operation. The controlscreen 601 for the Huawei Share function may further include a real-timestatus identifier (not shown in FIG. 6) for the Huawei Share function.The mobile phone may monitor a real-time status for the Huawei Sharefunction in a settings database in a manner of registration as anobserver. The real-time status identifier for the Huawei Share functionon the control screen 601 may be correspondingly updated depending on achange of the status for the Huawei Share function. The control screen601 for the Huawei Share function may further include a pop-up dialogbox (not shown in FIG. 6) for switching a visible range. The pop-updialog box is used for the user to switch the visible range for theHuawei Share function. The user may perform an operation on a settingsscreen or a notification option on a notification bar, to trigger themobile phone to display the pop-up dialog box on the touchscreen. Afterthe pop-up dialog box is displayed, the pop-up dialog box disappearswhen the status for the Huawei Share function changes. In someembodiments, when the user selects the visible range to be visible to“all devices”, when the mobile phone is connected to an open wirelessaccess point or allows password-free access from another electronicdevice, the mobile phone may display a pop-up window, to remind the userthat there is a risk of enabling the Huawei Share function. In addition,when the user enables the Huawei Share function, the mobile phone mayfurther verify a right of the user, for example, whether the user isallowed to enable the Huawei Share function and/or whether the user isallowed to obtain a Huawei account.

In some other embodiments of this application, when the user sets thedata sharing function for the first time, the first electronic devicemay display a series of guide screens, to guide the user to set the datasharing function. The first electronic device may further store asetting preference of the user, so that a sharing function can be setbased on the setting preference of the user next time.

In some other embodiments, as shown in FIG. 7(b), the first input mayalternatively be an operation performed by the user on a share on/offbutton 702 for the data sharing function on a notification bar 701displayed on the touchscreen of the mobile phone. The notification bar701 may be a screen displayed for the user on the touchscreen of themobile phone, for example, displayed after the user performs a swipingoperation on a home screen of the mobile phone according to a swipingtrack 703 shown in FIG. 7(a).

In some other embodiments of this application, the share on/off buttonfor the data sharing function may be a physical button. The button maybe disposed on a surface of the first electronic device. After a fingerof the user presses or switches the physical button (namely, the firstinput), the first electronic device enables the data sharing function.After a finger of the user presses or switches the physical buttonagain, the first electronic device may disable the data sharingfunction.

In some other embodiments of this application, the first input mayalternatively be an operation of automatically enabling, by the firstelectronic device, the data sharing function of the first electronicdevice when a specific condition is met.

For example, when the first electronic device and the second electronicdevice establish wireless connections to a same Wi-Fi hotspot, the firstelectronic device may automatically enable the data sharing function.After establishing the wireless connection to the Wi-Fi hotspot, thesecond electronic device may broadcast a Wi-Fi frame, where the Wi-Fiframe may carry an identifier of the Wi-Fi hotspot to which the secondelectronic device establishes the wireless connection, so that the firstelectronic device learns, based on the received Wi-Fi frame, whether thesecond electronic device and the first electronic device establish thewireless connections to the same Wi-Fi hotspot.

For another example, when the first electronic device and the secondelectronic device establish connections to a same Wi-Fi hotspot, and thefirst electronic device and the second electronic device trust eachother, the first electronic device automatically enables the datasharing function. That the first electronic device and the secondelectronic device trust each other may be that the first electronicdevice and the second electronic device are logged in by using a sameaccount. The account may be an account provided by an operator for theuser, such as a Xiaomi account or a Huawei account, or may be anapplication account, such as a WeChat account or a Youku account. TheWi-Fi frame may further carry the account, so that the first electronicdevice learns, based on the Wi-Fi frame, whether the second electronicdevice and the first electronic device are logged in by using the sameaccount. For example, when the first electronic device and the secondelectronic device establish the connections to the same Wi-Fi hotspot,the first electronic device obtains a second user identifier of thesecond electronic device, for example, a Huawei account used to log into the second electronic device, and determines whether the second useridentifier of the second electronic device is the same as a first useridentifier stored in the first electronic device, for example, a Huaweiaccount used to log in to the first electronic device. If the firstelectronic device determines that the second user identifier is the sameas the first user identifier, it indicates that the first electronicdevice and the second electronic device trust each other. In this case,the first electronic device may automatically enable the data sharingfunction. In addition, a notification message may be displayed on atouchscreen of the second electronic device, to notify the user that thefirst electronic device has enabled the data sharing function.

S402: The first electronic device enables the data sharing function inresponse to the first input, where the data sharing function is mainlyused for the user to access the shared data in the first electronicdevice from the second electronic device, and the second electronicdevice and the first electronic device are connected to a same localarea network.

When the user wants to access the shared data in the first electronicdevice from the second electronic device, the user may perform the firstinput, to enable the data sharing function of the first electronicdevice. In this way, when the first electronic device and the secondelectronic device are connected to the same local area network, the usercan access the shared data in the first electronic device from thesecond electronic device. To be specific, in some other embodiments ofthis application, the method may further include: establishing, by thefirst electronic device, a wireless connection to a wireless accesspoint, and establishing, by the second electronic device, a wirelessconnection to the wireless access point, so that the user can access theshared data in the first electronic device from the second electronicdevice subsequently. For example, the wireless access point may be aWi-Fi hotspot, or may be a Bluetooth beacon.

For example, with reference to FIG. 3, FIG. 5(a), and FIG. 5(b), whenthe user wants to access the shared data in the mobile phone from thenotebook computer, the user may perform, by using a finger, a touchoperation on the share on/off button 502 for the data sharing functionon the share control screen 501 displayed on the touchscreen of themobile phone. In this case, an application layer of an Android®operating system running on the mobile phone may detect the operation.After converting the detected operation into a request for enabling thedata sharing function, the application layer transfers the request to anapplication framework layer of the Android® operating system running onthe mobile phone. After receiving the request, the application frameworklayer invokes a service interface used for communication with a hardwareabstraction layer of the Android® operating system running on the mobilephone, to transfer the request for enabling the data sharing function tothe hardware abstraction layer. After receiving the request for enablingthe data sharing function, the hardware abstraction layer enables thedata sharing function of the mobile phone. For example, the hardwareabstraction layer may start the two daemon processes smbd/nmbd, toenable the data sharing function of the mobile phone. The daemon processsmbd can provide functions such as a data sharing service and user rightverification, and can enable an SMB service. The daemon process nmbd canenable the notebook computer to access a local file system at a Linuxkernel layer of the Android® operating system running on the mobilephone. A main function of the daemon process nmbd is to provide anetwork basic input/output system (NetBIOS) name service and enable annmb service, and a port 137 for the UDP protocol is used for the daemonprocess nmbd.

In some other embodiments of this application, after the data sharingfunction is enabled, a share status identifier may be further displayedon the touchscreen of the first electronic device, where the sharestatus identifier is used to indicate that the data sharing function hasbeen enabled. For example, after enabling the data sharing function, thehardware abstraction layer may send, to the application framework layer,a notification message indicating that the data sharing function hasbeen enabled. After receiving the notification message, the applicationframework layer forwards the notification message to the applicationlayer. After receiving the notification message, the application layermay display, on the touchscreen of the mobile phone, the share statusidentifier used to indicate that the data sharing function has beenenabled. For example, as shown in FIG. 8, the mobile phone may display ashare icon 802 on a status bar 801 displayed on the touchscreen of themobile phone, to indicate, to the user, that the data sharing functionof the mobile phone has been enabled.

In some other embodiments of this application, the user may further set,on the share control screen, a to-be-discovered share name of the firstelectronic device serving as a share server, a range of the shared datathat can be accessed by a share client, a user name and a password forlogin authentication, and the like.

For example, with reference to FIG. 3, FIG. 5(a), and FIG. 5(b), theuser wants to set a user name and a password for login authentication.As shown in FIG. 5(a), the user may perform an operation on a computeraccess verification option 503 on the share control screen 501. In thiscase, the application layer may detect the operation. The applicationlayer converts the operation into a request for setting a user name anda password for login authentication, and transfers the request to theapplication framework layer. After receiving the request, theapplication framework layer provides the application layer with afunction of setting a user name and a password for login authentication.In this case, as shown in FIG. 5(b), in response to the operation, theapplication layer may display, on the touchscreen of the mobile phonebased on the function provided by the application framework layer, adialog box 504 for setting a user name and a password. The user mayenter a corresponding user name and password in the dialog box 504 forsetting a user name and a password, and tap an OK button aftercompleting entering the user name and the password. The applicationlayer transmits the user name and the password that are entered by theuser to the application framework layer based on the user's tapoperation on the OK button. After receiving the user name and thepassword, the application framework layer invokes the service interfaceused for communication with the hardware abstraction layer, to transferthe received user name and password to the hardware abstraction layer.After receiving the user name and password, the hardware abstractionlayer stores the received user name and password in smbpasswd. In thiscase, setting a user name and a password for login authentication isimplemented. In some other embodiments of this application, the username and the password for login authentication may not only be stored insmbpasswd at the hardware abstraction layer, but also stored at theapplication framework layer in one copy. In this way, when validity ofthe user name and the password that are entered by the user on thecomputer side is verified, the valid user name and password can bequeried from the copy stored at the application layer. This reducesinteraction between the layers. In some other embodiments of thisapplication, the user may alternatively not set a user name and apassword for login authentication. In this case, default configurationsare used for a user name and a password for login authentication. Insome other embodiments of this application, during setting a user nameand a password for login authentication, if the user deletes a defaultuser name and password for login authentication, and does not set a newuser name and password for login authentication, the second electronicdevice does not need to enter a user name and a password and canautomatically access the first electronic device when accessing thefirst electronic device. In addition, in some embodiments of thisapplication, the first electronic device may further provide the userwith a screen for selecting whether access from the second electronicdevice needs to be verified, to determine whether to enable apassword-free access function.

For example, the user wants to set a to-be-discovered share name of themobile phone serving as the share server. As shown in FIG. 5(a), theuser may perform an operation on a computer-side displayed name option505 on the share control screen 501. In this case, the application layermay detect the operation. The application layer converts the operationinto a request for setting a to-be-discovered share name, and transfersthe request to the application framework layer. After receiving therequest, the application framework layer provides the application layerwith a function of setting a to-be-discovered share name. In this case,in response to the operation, the application layer may display, on thetouchscreen of the mobile phone based on the function provided by theapplication framework layer, a dialog box for setting a to-be-discoveredshare name. The user may enter a corresponding name in the dialog boxfor setting a to-be-discovered share name, and tap an OK button aftercompleting entering the name. The application layer transmits the nameentered by the user to the application framework layer based on theuser's tap operation on the OK button. The application framework layerreceives the name, and invokes the service interface used forcommunication with the hardware abstraction layer, to transfer thereceived name to the hardware abstraction layer. After receiving thename, the hardware abstraction layer stores the received name in an SMBconfiguration file. In this case, setting a to-be-discovered share nameis implemented. In some embodiments, before the user taps the OK button,the mobile phone may further verify validity of the to-be-discoveredshare name entered by the user, and the user can perform an operation onthe OK button only when the mobile phone detects that theto-be-discovered share name entered by the user is valid. If the mobilephone detects that the to-be-discovered share name entered by the useris invalid, the mobile phone may display a prompt dialog box indicating,to the user, that the to-be-discovered share name is invalid. In someother embodiments of this application, the to-be-discovered share namemay not only be stored in the SMB configuration file at the hardwareabstraction layer, but also stored at the application framework layer inone copy. In this way, when the to-be-discovered share name needs to bequeried subsequently, the to-be-discovered share name can be found fromthe copy stored at the application layer. This reduces interactionbetween the layers. In some other embodiments of this application, theuser may not set a to-be-discovered share name. In this case, a defaultconfiguration is used for the to-be-discovered share name. For example,as shown in FIG. 5, a default to-be-discovered share name of the mobilephone serving as the share server is PAT-123. If the user does notchange the to-be-discovered share name, a share server name found by thenotebook computer side is PAT-123.

After the data sharing function is enabled, when the first electronicdevice and the second electronic device are connected to the same localarea network, the user can find the first electronic device by using thesecond electronic device. Specifically, in some other embodiments ofthis application, as shown in FIG. 9A and FIG. 9B, the method forsharing data in a local area network may further include the followingoperations S403 to S411.

S403: The second electronic device receives second input.

For example, when the second electronic device is a Mac computer ofApple, the second input may be an operation on a network function of theMac computer. When the second electronic device is a Windows computer,the second input may be an operation on a network neighborhood icon onthe Windows computer. Alternatively, the second input may be anoperation on a prompt dialog box on a notification bar or a taskbar ofthe second electronic device. The prompt dialog box is used to indicatethat the first electronic device has enabled the data sharing function.Alternatively, the second input may be an operation on a related icon ona notification bar or a taskbar of the second electronic device. Theicon is used to enable a network-related function of the secondelectronic device.

S404: The second electronic device displays a first window in responseto the second input, where the first window includes an identifier ofthe first electronic device.

The identifier of the first electronic device may include a device iconof the first electronic device and/or a to-be-discovered share name ofthe first electronic device serving as a share server.

For example, as shown in FIG. 10, the first electronic device is amobile phone, and the second electronic device is a Mac notebookcomputer of Apple. The user enables a network function of the Macnotebook computer by using a Finder icon 1000 of the Mac notebookcomputer. In response to a user's click operation, the Mac notebookcomputer displays a first window 1001. The first window 1001 may be anetwork function details window on the Mac notebook computer, and thedetails window includes an identifier of the mobile phone. Specifically,as shown in FIG. 10, the details window includes an icon 1002 of themobile phone and a to-be-discovered share name 1003 of the mobile phoneserving as the share server, for example, PAT-123. For example, as shownin FIG. 11, the first electronic device is a mobile phone, and thesecond electronic device is a Windows notebook computer of Huawei. Theuser opens a network neighborhood of the Windows notebook computer. Inresponse to a user's click operation, the Windows notebook computerdisplays a first window 1101. The first window 1101 may be a networkneighborhood details window, and the details window includes anidentifier of the mobile phone. Specifically, as shown in FIG. 11, thedetails window includes an icon 1102 of the mobile phone and ato-be-discovered share name 1103 of the mobile phone serving as theshare server, for example, PAT-123.

In some embodiments of this application, as shown in FIG. 10 and FIG.11, the first window may include two parts of content: a common computernetwork neighborhood and an electronic device network neighborhood. Thecommon computer network neighborhood includes an identifier of a commoncomputer discovered by the second electronic device, and the electronicdevice network neighborhood includes the identifier of the firstelectronic device, for example, the mobile phone, discovered by thesecond electronic device. This helps the user differentiate a devicetype of the share server discovered by the second electronic device, forexample, determine whether the device type of the share server is acommon computer or a mobile phone. In some other embodiments of thisapplication, discovered devices on the first window may not bedifferentiated based on a device type of a share server.

For example, in some other embodiments, the user may perform anoperation on the prompt dialog box on the notification bar or thetaskbar of the second electronic device. Corresponding to the operation,the second electronic device opens the first window. In some otherembodiments, the user may perform an operation on the related icon onthe notification bar or the taskbar of the second electronic device.Corresponding to the operation, the second electronic device opens thefirst window.

S405: The second electronic device receives third input, where the thirdinput may be specifically an operation on the identifier of the firstelectronic device.

In some embodiments of this application, the operation on the identifierof the first electronic device may be specifically an operation on anicon of the first electronic device, or may be an operation on theto-be-discovered share name of the first electronic device.

S406: The second electronic device displays a second window in responseto the third input, where the second window is used to prompt the userto enter a user name and a password for login authentication.

The second window may also be referred to as a verification window, andis used to prompt the user to enter the user name and the password forlogin authentication.

When the first electronic device side does not allow password-freeaccess, after the user performs the operation on the identifier of thefirst electronic device on the first window shown in FIG. 10 or FIG. 11,in response to the operation, the second electronic device displays thesecond window for the user to enter the user name and the password forlogin authentication.

S407: The second electronic device adds, to access request information,the user name and the password that are entered by the user, and sendsthe access request information to the first electronic device.

After the second electronic device receives input confirmation of theuser, the second electronic device may add, to the access requestinformation, the user name and the password that are entered by theuser, and send the access request information to the first electronicdevice by using the foregoing wireless access point.

For example, with reference to FIG. 10, after the user performs a clickoperation on the identifier of the first electronic device on the firstwindow 1001 shown in FIG. 10, in response to the user's click operationon the identifier of the first electronic device, the Mac notebookcomputer displays a second window 1201 shown in FIG. 12, where thesecond window 1201 may include a pop-up dialog box for the user to enterthe user name and the password for login authentication. After the Macnotebook computer displays the pop-up dialog box, the user may enter theuser name and the password in the pop-up dialog box, and click a Connectbutton 1202 after completing entering the user name and the password. Inresponse to the user's click operation on the Connect button 1202, theMac notebook computer adds, to access request information, the user nameand the password that are entered by the user, and sends the accessrequest information to the mobile phone by using the wireless accesspoint.

With reference to FIG. 11, after the user performs a click operation onthe identifier of the first electronic device on the first window 1101shown in FIG. 11, in response to the user's click operation on theidentifier of the first electronic device, the Windows notebook computerdisplays a second window 1301 shown in FIG. 13, where the second window1301 may include a pop-up dialog box for the user to enter the user nameand the password for login authentication. After the Windows notebookcomputer displays the pop-up dialog box, the user may enter the username and the password in the pop-up dialog box, and click an OK button1302 after completing entering the user name and the password. Inresponse to the user's click operation on the OK button 1302, theWindows notebook computer adds, to access request information, the username and the password that are entered by the user, and sends the accessrequest information to the mobile phone by using the wireless accesspoint.

S408: The first electronic device receives the access requestinformation of the second electronic device from a first port, andverifies validity of the user name and the password that are carried inthe access request information.

The first port is a serving port for a local area network shared accessprotocol. For example, the local area network shared access protocol isthe SMB protocol. The first port may be a port 139/445 for the TCPprotocol.

After enabling the data sharing function, the first electronic devicemay listen on the first port, to learn in time whether there is anotherelectronic device that needs to access the first electronic device.After the first electronic device receives, from the first port, theaccess request information of the second electronic device forwarded byusing the wireless access point, the first electronic device may verifyvalidity of the second electronic device based on the access requestinformation. To be specific, the first electronic device may verify theuser name and the password that are entered by the user and that arecarried in the received access request information. For example, thevalidity verification operation may be performed by an applicationlayer, or may be performed by a hardware abstraction layer.

S409: After the validity verification succeeds, the first electronicdevice sends access response information to the second electronicdevice, where the access response information carries a classifiedshared directory.

The first electronic device may send the access response information tothe second electronic device by using the wireless access point, so thatthe shared data in the first electronic device is accessed from thesecond electronic device. The classified shared directory may include atleast one of the following: an internal storage directory and a commonfile directory. The internal storage directory is a directory of alldata stored in a memory of the first electronic device. In someembodiments of this application, the common file directory may be adirectory of data that is stored in the memory of the first electronicdevice and that meets a specific condition. For example, the common filedirectory is a directory of data that is stored in the memory of thefirst electronic device and whose user's access frequency is greaterthan a threshold. In some other embodiments of this application, thecommon file directory may be a directory of specific data, for example,a video, a picture, or music, stored in the memory of the firstelectronic device. In addition, the common file directory can be mappedto a directory in which corresponding data is actually stored in thememory of the first electronic device. In some embodiments of thisapplication, the classified shared directory may be dynamically updated.For example, an application framework layer may monitor the shared datain the mobile phone, and when detecting that the shared data in themobile phone changes, the application framework layer notifies thehardware abstraction layer, so that the hardware abstraction layerupdates the shared directory.

For example, the common file directory is a picture directory, to bespecific, the classified shared directory includes the internal storagedirectory and an album directory. The classified shared directory may beshown in Table 1.

TABLE 1 Mobile phone Album Camera 1.jpg 2.jpg 3.jpg WeChat Screenrecording and screenshot Magazine unlock Bluetooth share Internalstorage Android Data 0bb obj AnyMail AnyOffice . . . WLAN Direct

It can be learned from Table 1 that the classified shared directoryincludes the album directory and the internal storage directory. Thealbum directory includes a camera subdirectory, a WeChat subdirectory, amagazine unlock subdirectory, and a Bluetooth share subdirectory. Eachsubdirectory includes one or more picture files. The internal storagedirectory includes an Android subdirectory, an AnyMail subdirectory, anAnyOffice subdirectory, a WLAN Direct subdirectory, and the like. Eachsubdirectory includes various types of data.

After the validity verification of the second electronic devicesucceeds, the first electronic device may send, to the second electronicdevice, the access response information that carries the classifiedshared directory, so that the user can access the shared data in thefirst electronic device by using the shared directory on the secondelectronic device.

In some other embodiments of this application, after the validityverification performed by the first electronic device on the secondelectronic device succeeds, the first electronic device may furtherdisplay a notification message, to notify the user that the device hassuccessfully established a connection to the first electronic device,and the user can access the shared data in the first electronic device.For example, the hardware abstraction layer performs the validityverification. After the validity verification performed by the hardwareabstraction layer on the second electronic device succeeds, the hardwareabstraction layer may send, to the application framework layer, anotification message indicating that the electronic device hassuccessfully established a connection to the mobile phone, and theelectronic device can access the mobile phone. After receiving thenotification message, the application framework layer forwards thenotification message to the application layer. After receiving thenotification message, the application layer may display, on anotification bar or a status bar displayed on a touchscreen of themobile phone, the notification message indicating that the electronicdevice has successfully established a connection to the mobile phone,and the electronic device can access the mobile phone. For example, asshown in FIG. 14, the mobile phone may display a notification message1402 on a notification bar 1401 displayed on the touchscreen of themobile phone, to notify the user that the electronic device hassuccessfully established a connection to the mobile phone, and theelectronic device can access the mobile phone.

In some other embodiments of this application, when the first electronicdevice side allows password-free access, after the user performs theoperation on the identifier of the first electronic device on the firstwindow shown in FIG. 10 or FIG. 11, in response to the user's operationon the identifier of the first electronic device, the second electronicdevice may send the access request information to the first electronicdevice, to request to access the first electronic device.

S410: The second electronic device receives the access responseinformation from the first electronic device.

S411: The second electronic device displays a third window based on theaccess response information, where the third window includes a foldercorresponding to the classified shared directory.

After receiving the access response information from the firstelectronic device, the second electronic device may display, based onthe access response information, the third window including the foldercorresponding to the classified shared directory, and the user mayperform an operation on the folder or data in the folder based on arequirement.

For example, with reference to the example in S409 and FIG. 12, as shownin FIG. 15, after receiving the access response information, the Macnotebook computer displays a third window 1501. The third windowincludes an internal storage folder 1502 and an album folder 1503. Theinternal storage folder 1502 corresponds to the internal storagedirectory, and the album folder 1503 corresponds to the album directory.After performing an operation on a folder, the user accesses a directorycorresponding to the folder. This implements access to data stored inthe first electronic device.

For example, the user performs a click operation on the album folder1503 on the third window 1501. As shown in FIG. 16, in response to theuser's click operation on the album folder 1503, the Mac notebookcomputer displays a window 1601. The window 1601 includes a camerafolder, a WeChat folder, a magazine unlock folder, and a Bluetooth sharefolder. The camera folder, the WeChat folder, the magazine unlockfolder, and the Bluetooth share folder respectively correspond to thecamera subdirectory, the WeChat subdirectory, the magazine unlocksubdirectory, and the Bluetooth share subdirectory. The user may performan operation, such as copy, delete, or rename, on a folder or data in afolder displayed on the window 1601. For example, as shown in FIG. 17,the user may copy all data in the WeChat folder 1702 to the desktop ofthe Mac notebook computer, and the Mac notebook computer may display apop-up window 1702, to indicate, to the user, progress of copying thedata in the WeChat folder 1702 to the desktop of the Mac notebookcomputer. In addition, when the user performs an operation on the shareddata in the first electronic device by using the second electronicdevice, the second electronic device may send a corresponding operationrequest to the first electronic device; and after receiving theoperation request, the first electronic device may return acorresponding operation response, so that the second electronic devicecan correspondingly perform the operation on the shared data in thefirst electronic device based on the operation of the user.

In some other embodiments of this application, after the data sharingfunction of the first electronic device is enabled, the first electronicdevice may further dynamically monitor a status of the connectionbetween the first electronic device and the wireless access point. Ifthe first electronic device detects that the connection between thefirst electronic device and the wireless access point is disconnected,the first electronic device may automatically disable the data sharingfunction, thereby reducing power consumption of the first electronicdevice. In addition, the first electronic device may further display anotification message on the touchscreen of the first electronic device,to notify the user that the first electronic device has automaticallydisabled the data sharing function because the first electronic deviceis disconnected from the wireless access point.

In some other embodiments of this application, the first electronicdevice may further monitor a local area network switching event of thefirst electronic device. When detecting that the wireless connectionbetween the first electronic device and the currently connected wirelessaccess point is disconnected and that the first electronic device isconnected to a new wireless access point, the first electronic devicemay also automatically disable the data sharing function of the firstelectronic device. This can effectively prevent unauthorized access tothe first electronic device by another electronic device connected tothe new wireless access point, especially when the first electronicdevice allows password-free access. In addition, the first electronicdevice may further display a notification message on the touchscreen ofthe first electronic device, to notify the user that the firstelectronic device has automatically disabled the data sharing functionbecause the first electronic device is connected to the new wirelessaccess point.

In some other embodiments of this application, after the user finishesaccessing the shared data in the first electronic device from the secondelectronic device, the user may disable the data sharing function of thefirst electronic device. In this case, the application layer may detecta user's operation of disabling the data sharing function. Theapplication layer converts the operation into a request for disablingthe data sharing function, and transfers the request to the applicationframework layer. After receiving the request, the application frameworklayer invokes a service interface used for communication with thehardware abstraction layer, to transfer the request for disabling thedata sharing function to the hardware abstraction layer. After receivingthe request for disabling the data sharing function, the hardwareabstraction layer disables the data sharing function of the mobilephone.

According to the method for sharing data in a local area networkprovided in this embodiment of this application, the first electronicdevice that supports the local area network shared access protocolreceives an operation of enabling the data sharing function, and enablesthe data sharing function in response to the operation, where the datasharing function is mainly used for the user to access the shared datain the first electronic device from the second electronic device, andthe second electronic device and the first electronic device areconnected to a same local area network. In this way, there is no need toinstall any software on the first electronic device and the secondelectronic device, there is no need to connect the first electronicdevice and the second electronic device by using a USB cable, and thedata stored in the first electronic device can be accessed quickly andconveniently from the second electronic device, provided that the firstelectronic device and the second electronic device are connected to thesame local area network. In addition, both the Mac notebook computer ofApple and another Windows notebook computer support the local areanetwork shared access protocol. Therefore, even if an operating systemof the first electronic device, for example, the mobile phone, isincompatible with an operating system of a notebook computer, datastored in the mobile phone can be accessed from the notebook computer byusing the method in this application.

It may be understood that, to implement the foregoing functions, theelectronic device includes a corresponding hardware structure and/orsoftware module for performing each function. A person skilled in theart should easily be aware that, in combination with the examplesdescribed in the embodiments disclosed in this specification, units,algorithms, and steps may be implemented by hardware or a combination ofhardware and computer software. Whether a function is performed byhardware or hardware driven by computer software depends on particularapplications and design constraints of the technical solutions. A personskilled in the art may use different methods to implement the describedfunctions for each particular application, but it should not beconsidered that the implementation goes beyond the scope of theembodiments of this application.

An embodiment of this application further provides an electronic devicefor implementing the foregoing method embodiments. Specifically, theelectronic device may be divided into functional modules. For example,each functional module may be obtained through division based on eachcorresponding function, or two or more functions may be integrated intoone processing module. The integrated module may be implemented in aform of hardware, or may be implemented in a form of a softwarefunctional module. It should be noted that, in this embodiment of thisapplication, division into the modules is an example and is merelylogical function division, and may be other division in an actualimplementation.

When each functional module is obtained through division based on eachcorresponding function, FIG. 18 is an schematic structural diagram of anelectronic device 1800 according to the foregoing embodiment. Theelectronic device 1800 may include a connection unit 1801, a receivingunit 1802, a verification unit 1803, and a sending unit 1804.

The connection unit 1801 is configured to support the electronic deviceto perform an operation of establishing a connection between theelectronic device and a wireless access point in the foregoing methodembodiment.

The receiving unit 1802 is configured to support the electronic deviceto perform S407 in the foregoing method embodiment and/or configured toperform another technical process described in this specification. Aninput unit may be a touchscreen, another hardware, or a combination ofhardware and software.

The verification unit 1803 is configured to support the electronicdevice to perform S408 in the foregoing method embodiment and/orconfigured to perform another technical process described in thisspecification.

The sending unit 1804 is configured to support the electronic device toperform S409 in the foregoing method embodiment and/or configured toperform another technical process described in this specification.

Further, in this embodiment of this application, as shown in FIG. 18,the electronic device 1800 may further include an input unit 1805 and acontrol unit 1806.

The input unit 1805 is configured to receive input of a user on adisplay screen of the electronic device, for example, touch input, voiceinput, gesture input, or a floating operation, and the input unit 1805is configured to support the electronic device to perform S401 in theforegoing method embodiment and/or configured to perform anothertechnical process described in this specification. The input unit may bea touchscreen, another hardware, or a combination of hardware andsoftware.

The control unit 1806 is configured to support the electronic device toperform S402 in the foregoing method embodiment and/or configured toperform another technical process described in this specification.

Further, in this embodiment of this application, as shown in FIG. 18,the electronic device 1800 may further include a display unit 1807.

The display unit 1807 is configured to support the electronic device toperform a displaying operation in the foregoing method embodiment and/orconfigured to perform another technical process described in thisspecification.

All related content of the operations in the foregoing method embodimentmay be cited in function descriptions of the corresponding functionalmodules. Details are not described herein again.

Certainly, the electronic device includes but is not limited to theunits and modules listed above. In addition, functions that can bespecifically implemented by the functional units include but are notlimited to functions corresponding to the method operations in theforegoing examples. For detailed descriptions of other units of theelectronic device 1800, refer to the detailed descriptions of the methodoperations corresponding to the units. Details are not described againin this embodiment of this application.

When an integrated unit is used, FIG. 19 is an schematic structuraldiagram of an electronic device 1900 according to the foregoingembodiment. The electronic device 1900 includes a processing module1901, a storage module 1902, and a display module 1903. The processingmodule 1901 is configured to control and manage an action of theelectronic device 1900. The display module 1903 is configured to displaycontent according to an instruction of the processing module 1901. Thestorage module 1902 is configured to store program code and data of theelectronic device 1900. Further, the electronic device 1900 may furtherinclude an input module and a communications module. The communicationsmodule is configured to support the electronic device 1900 tocommunicate with another network entity, to implement functions of theelectronic device such as calling, data exchange, and internet access.

The processing module 1901 may be a processor or a controller. Thecommunications module may be a transceiver, an RF circuit, acommunications interface, or the like. The storage module 1902 may be amemory. The display module may be a screen or a display. The inputmodule may be a touchscreen, a voice input apparatus, a fingerprintsensor, or the like.

When the processing module 1901 is the processor, the communicationsmodule is the RF circuit, the storage module 1902 is the memory, and thedisplay module 1903 is a touchscreen, the electronic device 1900provided in this embodiment of this application may be the mobile phoneshown in FIG. 2. The communications module may include not only the RFcircuit, but also a Wi-Fi module, an NFC module, and a Bluetooth module.The communications modules such as the RF circuit, the NFC module, theWi-Fi module, and the Bluetooth module may be collectively referred toas the communications interface. The processor, the RF circuit, thetouchscreen, and the memory may be coupled together by using a bus.

An embodiment of this application further provides a computer storagemedium. The computer storage medium stores computer program code, andwhen the foregoing processor executes the computer program code, theelectronic device performs related method operations in any accompanyingdrawing of FIG. 4 or FIG. 9A and FIG. 9B to implement the supplementaryservice setting method in the foregoing embodiment.

An embodiment of this application further provides a computer programproduct. When the computer program product is run on a computer, thecomputer is enabled to perform related method operations in anyaccompanying drawing of FIG. 4 or FIG. 9A and FIG. 9B to implement thesupplementary service setting method in the foregoing embodiment.

An embodiment of this application further provides a control device. Thecontrol device includes a processor and a memory. The memory isconfigured to store computer program code, and the computer program codeincludes a computer instruction. When the processor executes thecomputer instruction, the control device performs related methodoperations in any accompanying drawing of FIG. 4 or FIG. 9A and FIG. 9Bto implement the supplementary service setting method in the foregoingembodiment. The control device may be an integrated circuit IC, or maybe a system on chip SOC. The integrated circuit may be a universalintegrated circuit, or may be a field programmable gate array FPGA, ormay be an application-specific integrated circuit ASIC.

An embodiment of this application further provides a programorchestration apparatus. The apparatus has a function of implementingbehavior of the electronic device in the foregoing method embodiment.The function may be implemented by hardware, or may be implemented byhardware executing corresponding software. The hardware or the softwareincludes one or more modules corresponding to the foregoing function.

The electronic device, the computer storage medium, the computer programproduct, or the control device provided in the embodiments of thisapplication is configured to perform the corresponding method describedabove. Therefore, for beneficial effects that can be achieved, refer tothe beneficial effects of the corresponding method described above.Details are not described herein again.

The foregoing descriptions about implementations allow a person skilledin the art to understand that, for the purpose of convenient and briefdescription, division of the foregoing functional modules is taken as anexample for illustration. In actual application, the foregoing functionscan be allocated to different modules and implemented based on arequirement, that is, an inner structure of an apparatus is divided intodifferent functional modules to implement all or some of the functionsdescribed above. For a detailed working process of the foregoing system,apparatus, and unit, refer to a corresponding process in the foregoingmethod embodiments, and details are not described herein again.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, division into the moduleor unit is merely logical function division and may be other division inan actual implementation. For example, a plurality of units orcomponents may be combined or integrated into another system, or somefeatures may be ignored or not performed. In addition, the displayed ordiscussed mutual couplings or direct couplings or communicationconnections may be implemented by using some interfaces. The indirectcouplings or communication connections between the apparatuses or unitsmay be implemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or may beimplemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of theembodiments of this application essentially, or the part contributing tothe prior art, or all or some of the technical solutions may beimplemented in the form of a software product. The computer softwareproduct is stored in a storage medium and includes several instructionsfor instructing a computer device (which may be a personal computer, aserver, or a network device) to perform all or some of the operations ofthe methods described in the embodiments of this application. Theforegoing storage medium includes: any medium that can store programcode, such as a flash memory, a removable hard disk, a read-only memory,a random access memory, a magnetic disk, or an optical disc.

The foregoing descriptions are merely specific implementations of theembodiments of this application, but are not intended to limit theprotection scope of the embodiments of this application. Any variationor replacement within the technical scope disclosed in the embodimentsof this application shall fall within the protection scope of theembodiments of this application. Therefore, the protection scope of theembodiments of this application shall be subject to the protection scopeof the claims.

1-4. (Canceled)
 5. A method of sharing data in a local area network,wherein the method comprises: establishing, by a first electronicdevice, a wireless connection to a Wi-Fi hotspot; establishing, by asecond electronic device, a wireless connection to the Wi-Fi hotspot;receiving, by the second electronic device, second input; displaying anidentifier of the first electronic device on the second electronicdevice in response to receiving the second input, wherein the identifierof the first electronic device comprises a device icon and ato-be-discovered share name; receiving, by the second electronic device,third input; displaying a verification window on the second electronicdevice in response to re the third input, wherein the verificationwindow prompts a user to enter a user name and a password for loginauthentication; in response to receiving input confirmation, adding, bythe second electronic device to access request information, the username and the password that are entered by the user for loginauthentication, and sending the access request information to the firstelectronic device using the Wi-Fi hotspot; receiving, by the firstelectronic device, the access request information from a first port,wherein the first port is a serving port for the server message block(SMB) protocol; verifying, by the first electronic device, validity ofthe second electronic device based on the access request information;and sending, by the first electronic device, access response informationto the second electronic device using the Wi-Fi hotspot when the firstelectronic device determines that the verification of the secondelectronic device succeeds, so that shared data in the first electronicdevice is accessed from the second electronic device, wherein the accessresponse information comprises an internal storage directory and acommon file directory.
 6. The method according to claim 5, whereinbefore the receiving, by the second electronic device, second input, themethod further comprises: obtaining, by the first electronic device, asecond user identifier of the second electronic device; determining, bythe first electronic device, whether the second user identifier is thesame as a first user identifier stored in the first electronic device;when the first electronic device determines that the second useridentifier is the same as the first user identifier, automaticallyenabling, by the first electronic device, a data sharing function; anddisplaying, by the second electronic device, notification information,wherein the notification information indicates that the first electronicdevice has enabled the data sharing function.
 7. The method according toclaim 5, wherein before the receiving, by the second electronic device,second input, the method further comprises: receiving, by the firstelectronic device, first input; and enabling, by the first electronicdevice, a data sharing function in response to the first input.
 8. Themethod according to claim 5, wherein the identifier of the firstelectronic device and an identifier of a third electronic device arecomprised in different directories in a network neighborhood of thesecond electronic device, and the third electronic device is a computerthat has enabled a data sharing function.
 9. The method according toclaim 5, wherein the first port is a transmission control protocol TCPport 139 or
 445. 10. A system for sharing data in a local area network,wherein the system comprises a first electronic device and a secondelectronic device, and the first electronic device is a mobile phone;the first electronic device and the second electronic device areconnected to a same wireless access point; the first electronic devicereceives, from a first port, access request information of the secondelectronic device forwarded using the wireless access point, wherein thefirst port is a serving port for a local area network shared accessprotocol; the first electronic device verifies validity of the secondelectronic device based on the access request information; and when thefirst electronic device determines that the verification of the secondelectronic device succeeds, the first electronic device sends accessresponse information to the second electronic device using the wirelessaccess point, so that shared data in the first electronic device isaccessed from the second electronic device, wherein the access responseinformation comprises an internal storage directory and a common filedirectory; the second electronic device receives second input, anddisplays an identifier of the first electronic device on the secondelectronic device in response to receivng the second input, wherein theidentifier of the first electronic device comprises a device icon and ato-be-discovered share name; the second electronic device receives thirdinput, and displays a verification window on the second electronicdevice in response to receiving the third input, wherein theverification window prompts a user to enter a user name and a passwordfor login authentication; and in response to receiving inputconfirmation, the second electronic device adds, to the access requestinformation, the user name and the password that are entered by the userfor login authentication, and sends the access request information tothe first electronic device -by using the Wi-Fi hotspot.
 11. (canceled)12. The system according to claim 10, wherein the identifier of thefirst electronic device and an identifier of a third electronic deviceare comprised in different directories in a network neighborhood of thesecond electronic device, and the third electronic device is a computerthat has enabled a data sharing function.
 13. A method of sharing datain a local area network, wherein the method comprises: establishing, bya second electronic device, a wireless connection to a wireless fidelityWi-Fi hotspot; establishing, by a first electronic device, a wirelessconnection to the Wi-Fi hotspot; obtaining, by the first electronicdevice, a second user identifier of the second electronic device;determining, by the first electronic device, whether the second useridentifier is the same as a first user identifier stored in the firstelectronic device; if the first electronic device determines that thesecond user identifier is the same as the first user identifier,automatically enabling, by the first electronic device, a data sharingfunction; displaying, by the second electronic device, notificationinformation, wherein the notification information indicates that thefirst electronic device has enabled the data sharing function;receiving, by the second electronic device, second input; displaying anidentifier of the first electronic device on the second electronicdevice in response to receiving the second input, wherein the identifierof the first electronic device comprises a device icon and ato-be-discovered share name; receiving, by the second electronic device,third input; displaying a verification window on the second electronicdevice in response to receiving the third input, wherein theverification window is used to prompt a user to enter a user name and apassword for login authentication; after receiving input confirmation,adding, by the second electronic device to access request information,the user name and the password that are entered by the user for loginauthentication, and sending the access request information to the firstelectronic device using the Wi-Fi hotspot; receiving, by the firstelectronic device, the access request information from a first port,wherein the first port is a serving port for the server message blockSMB protocol; verifying, by the first electronic device, validity of thesecond electronic device based on the access request information; andwhen the first electronic device determines that the verification of thesecond electronic device succeeds, sending, by the first electronicdevice, access response information to the second electronic deviceusing the Wi-Fi hotspot, so that shared data in the first electronicdevice is accessed from the second electronic device, wherein the accessresponse information comprises an internal storage directory and acommon file directory. 14-20. (canceled)
 21. A first electronic device,comprising: a touchscreen; one or more processors; and a memory forstoring instructions which, when executed by the one or more processors,cause the first electronic device to: establish a wireless connection toa wireless access point; receive, from a first port, access requestinformation of a second electronic device forwarded using the wirelessaccess point, wherein the first port is a serving port for a local areanetwork shared access protocol, and the second electronic deviceestablishes a wireless connection to the wireless access point; verifyvalidity of the second electronic device based on the access requestinformation; and when the verification unit determines that theverification of the second electronic device succeeds, send accessresponse information to the second electronic device using the wirelessaccess point, so that shared data in the first electronic device isaccessed from the second electronic device, wherein the access responseinformation comprises an internal storage directory and a common filedirectory.
 22. The first electronic device according to claim 21,wherein the first electronic device is further caused to: receive firstinput; and enable a data sharing function in response to the first inputreceived by the input unit.
 23. The first electronic device according toclaim 22, wherein the electronic device is further caused to: display ashare control screen, wherein the share control screen comprises a shareon/off button; and receive the first input for the share on/off button.24. The first electronic device according to claim 21, wherein thewireless access point is a wireless fidelity Wi-Fi hotspot or aBluetooth beacon; and the local area network file sharing protocol isthe server message block SMB protocol;
 25. The first electronic deviceaccording to claim 21, wherein the first port is a transmission controlprotocol TCP port 139 or
 445. 26. The first electronic device accordingto claim 21, wherein the electronic device is further caused to: displayprompt information when it is determined that the wireless connectionbetween the first electronic device and the wireless access point isdisconnected and that a wireless connection is established to anotherwireless access point, wherein the prompt information is used toindicate that the first electronic device establishes the wirelessconnection to the another wireless access point.